home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh -f
- #
- # $Id: Setrcsname,v 1.5 93/12/16 14:48:11 carlson Exp $
- #
- # Setrcsname Sets a name for a revision of every RCS file.
- #
- # Synopsis:
- # Setrcsname -n <name> [-l] [file-list]
- # Setrcsname -n <name>:<rev> [-m] [file-list]
- # Setrcsname -N <name> [-l] [file-list]
- # Setrcsname -N <name>:<rev> [-m] [file-list]
- #
- # Description:
- # This script sets a symbolic name for a revison of an RCS file.
- #
- # In the first form, if the -l is not provided, the symbolic
- # name is deleted (if it exists). Otherwise, the last revision
- # has the last component removed and is used as the revision.
- # If the symbolic name already exists for another revision, an
- # error is printed by rcs.
- #
- # In the second form, the specified revision is given the
- # symbolic name. If the symbolic name already exists for
- # another revision, an error is printed by rcs.
- #
- # The third form is identical to the first form except if the
- # symbolic name already exists for another revision, it is
- # overridden.
- #
- # The fourth form is identical to the second form except it the
- # symbolic name already exists for another revision, it is
- # overridden.
- #
- # Parameters:
- # -n <name> Symbolic name to define.
- # -N <name> Symbolic name to define and override if it exists.
- # -l Use last revision of file to set symbolic name to.
- # -m Set symbolic name only if revision exists.
- #
- # Revision History:
- # $Log: Setrcsname,v $
- # Revision 1.5 93/12/16 14:48:11 carlson
- # Added the ability to provide an actual file list to perform the function
- # to on the command line.
- #
- # Revision 1.4 92/10/27 10:05:50 carlson
- # Put checking of options in an if statement that is dependent on whether
- # there are any options. This allowed the usage statement to be printed
- # if no options or arguments are provided.
- #
- # Revision 1.3 92/08/21 16:31:00 carlson
- # Added more output to when called with no parameters.
- #
- # Revision 1.2 91/07/27 20:07:12 chris
- # Completely revamped this script. Provide all kinds of ways to set
- # a symbolic name to a bunch of RCS files.
- #
- #---------------------------------------------------------------------------
-
- set name = ""
- set last = 0
- set override = 0
- set modify = 0
-
- if ( $#argv >= 1 ) then
- set argv = `getopt lmn:N: $*`
- while ( "$1" != "--" )
- switch ( $1 )
- case "-l":
- set last = 1
- shift
- breaksw
-
- case "-m":
- set modify = 1
- shift
- breaksw
-
- case "-n":
- set name = $2
- shift; shift
- breaksw
-
- case "-N":
- set name = $2
- set override = 1
- shift; shift
- breaksw
- endsw
- end
- shift
- endif
-
- if ( "$name" == "" ) then
- echo "Usage: Setrcsname -n <name> [-l] [file-list]"
- echo " Setrcsname -n <name>:<rev> [-m] [file-list]"
- echo " Setrcsname -N <name> [-l] [file-list]"
- echo " Setrcsname -N <name>:<rev> [-m] [file-list]"
- echo " -n <name> Symbolic name to define."
- echo " -N <name> Symbolic name to define and override if it exists."
- echo " -l Use last revision of file to set symbolic name to."
- echo " -m Set symbolic name only if revision exists."
- echo " [file-list] Optional list of files to do."
- exit
- endif
-
- #----
- # rev = revision portion of name provided (everything after :)
- # name = name portion (everything before :)
- # Revc = revision preceded by colon
- #
- set rev = `echo $name | awk -F: '{ print $2 }'`
- set name = `echo $name | awk -F: '{ print $1 }'`
-
- if ( "$rev" != "" ) then
- set last = 0
- set Revc = :$rev
- else
- set modify = 0
- set Revc = ""
- endif
-
- #----
- # If no files were provided on the command line,
- # loop through each RCS file found. If there is an RCS directory,
- # loop through the files ending in ",v" in it. Otherwise, loop
- # through files in the current directory ending in ",v".
- #
- set rcsdir = ""
- if ( -d RCS ) set rcsdir = "RCS/"
-
- if ( $#argv == 0 ) then
- set fileList = `ls ${rcsdir}*,v`
- else
- set fileList = ( $argv )
- endif
-
- foreach rcsfile ( $fileList )
- set file = `basename $rcsfile ,v`
-
- #----
- # If we are supposed to set the last revision, get the last
- # revision and remove the last component.
- #
- # If we are only to set the symbolic name if the revision exists,
- # check if the revision exists and skip if not there.
- #
- if ( $last ) then
- set rev = `rlog $file | grep "^head:" | awk '{print $NF}'`
- set Rev = `echo $rev | awk -F. '{for(i=1;i<NF-1;i++)printf "%s.",$i;print $i}'`
- set Revc = :$Rev
- else if ( $modify ) then
- set x = `rlog $file | grep "^revision $rev"`
- if ( "$x" == "" ) continue
- endif
-
- if ( $override ) then
- rcs -N${name}${Revc} $file
- else
- rcs -n${name}${Revc} $file
- endif
- end
-
- ### Local Variables:
- ### auto-fill-hook: nil
- ### End:
-